package biz

import (
	"context"

	"github.com/go-kratos/kratos/v2/errors"
	"github.com/go-kratos/kratos/v2/log"
)

var (
	ErrNodeNotFound = errors.NotFound("NODE_NOT_FOUND", "节点不存在")
)

type NodeRepo interface {
	// GetNodesByName 根据名称获取节点信息
	GetNodesByName(context.Context, string) ([]string, error)
}
type NodeUsecase struct {
	repo NodeRepo
	log  *log.Helper
}

// NewNodeUsecase .
func NewNodeUsecase(repo NodeRepo, logger log.Logger) *NodeUsecase {
	return &NodeUsecase{
		repo: repo,
		log:  log.NewHelper(log.With(logger, "module", "usecase/node")),
	}
}

func (n *NodeUsecase) GetNodes(ctx context.Context, name string) ([]string, error) {
	return n.repo.GetNodesByName(ctx, name)
}
